/*
 * ============================================================================
 *
 *       Filename:  main.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年06月16日 16时11分30秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * ============================================================================
 */
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <time.h>

#define RANDOMDEV 	"/dev/urandom"

int main()
{
	FILE *file = fopen(RANDOMDEV, "r");
	if(!file) {
		fprintf(stderr, "fopen %s failed: %s(%d)\n",
			RANDOMDEV, strerror(errno), errno);
		return -1;
	}

	int nread;
	unsigned long long random;
	nread = fread(&random, 1, sizeof(random), file);
	if(nread != sizeof(random)) {
		fprintf(stderr, "fread failed\n");
		return -1;
	}
	fclose(file);

	unsigned long long ti;
	ti = (unsigned long long)time(NULL);

	random += ti;
	printf("%llu\n", random);
	return 0;
}
